package com.joker.yuwu;

import com.joker.repository.YdZhanguan;
import net.sf.json.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

//用户预定展馆访问该接口
@WebServlet("/yudingzg")

public class YDzg extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doGet(req, resp);
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/json; charset=utf-8");
        String user=req.getParameter("user");
        String zgname=req.getParameter("zhanguan");
        System.out.println("用户id为"+user);
        System.out.println("预定展馆名:"+zgname);

        JSONObject obj=new JSONObject();


        YdZhanguan y1=new YdZhanguan();
        boolean b1=y1.Show(user,zgname);
        obj.put("data",b1);
        resp.getWriter().write(obj.toString());

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doPost(req, resp);
        req.setCharacterEncoding("utf-8");
        String user=req.getParameter("1");
        System.out.println("用户id为");
        resp.getWriter().write("成功");
    }
}
